﻿using AutoMapper;
using B.S.Packaged.Domain;
using B.S.Packaged.ErrorCode;
using B.S.Packaged.WebAPI.Read.Application.Command.CompletedStorageCommand;
using MediatR;
using SqlSugar;

namespace B.S.Packaged.WebAPI.Read.Application.CommandHander.CompletedStorageHandler
{
    public class FTCompletedStorageHandler : IRequestHandler<FTCompletedStorageCommand, APIResult<List<CompletedStorage>>>
    {

        private readonly ISqlSugarClient db;
        private readonly IMapper mapper;
        public FTCompletedStorageHandler(ISqlSugarClient db, IMapper mapper)
        {
            this.db = db;
            this.mapper = mapper;
        }
        public async Task<APIResult<List<CompletedStorage>>> Handle(FTCompletedStorageCommand request, CancellationToken cancellationToken)
        {
            APIResult<List<CompletedStorage>> result = new APIResult<List<CompletedStorage>>();
            var list = await db.Queryable<CompletedStorage>().Where(x => x.IsDel == false && x.id == request.id).ToListAsync();
            result.data = list;
            result.code = APIResultCode.success;
            result.msg = "完工入库显示成功";
            return await Task.FromResult(result);
        }
    }
}
